<template>
	<view>
		<view class="IncreaseInformation">
			已有6523515人完成该项信息后成功下款
		</view>
		<view class="IncreaseInformationHead">
			<text style="float: left;margin-right: 100rpx;">是否有车</text>
			<picker @change="bindPickerChange" :value="index" :range="list">
			    <view class="uni-input">{{list[index]}}</view>
			</picker>
			<image src="../../static/bottom.png" class="SupplementHeadImg" mode=""></image>
		</view>
		<view class="IncreaseInformationHead1" v-if="Driving" @click="IncreaseInformationClick(1)">
			<text style="margin-right: 100rpx;">行驶证认证</text>
			<text v-if="license" style="background: #FBE5CE;border-radius: 23rpx;padding: 6rpx 20rpx;font-size: 30rpx;font-family: PingFang SC;font-weight: 400;color: #DFAF80;float: right;background: #FBE5CE;color: #DFAF80;">去认证</text>
			<text v-if="!license" style="background: #FBE5CE;border-radius: 23rpx;padding: 6rpx 20rpx;font-size: 30rpx;font-family: PingFang SC;font-weight: 400;color: #DFAF80;float: right;background: #F8F8F8;color: #888888;">已认证</text>
		</view>
		<view class="IncreaseInformationHead">
			<text style="float: left;margin-right: 100rpx;">是否有房</text>
			<picker @change="bindPickerChange2" :value="index2" :range="list2">
			    <view class="uni-input">{{list2[index2]}}</view>
			</picker>
			<image src="../../static/bottom.png" class="SupplementHeadImg" mode=""></image>
		</view>
		<view class="IncreaseInformationHead">
			<text style="float: left;margin-right: 70rpx;">是否有保单</text>
			<picker @change="bindPickerChange3" :value="index3" :range="list3">
			    <view class="uni-input">{{list3[index3]}}</view>
			</picker>
			<image src="../../static/bottom.png" class="SupplementHeadImg" mode=""></image>
		</view>
		<view class="IncreaseInformationBottom">
			<view class="IncreaseInformationBottomInput" @click="TiJiaoClick">
				提交
			</view>
			<view style="font-size: 24rpx;font-family: PingFang SC;font-weight: 400;color: #888888;margin-top: 10rpx;">
				信息仅用做审批借款额度，将加密保障您的信息安全
			</view>
		</view>
	</view>
</template>

<script>
	import {VUE_API_URL , VUE_API_URL_IMG} from "@/components/pulugins/index"
	export default {
		components: {
			
		},
		data() {
			return {
				list:['否','是'],
				list2:['否','是'],
				list3:['否','是'],
				index: 0,
				index2:0,
				index3:0,
				Driving:false,
				license:true,		//行驶证是否认证
				xszxx:'',
				license_positive:'',
				license_side:''
			}
		},
		computed: {
		    startDate() {
		        return this.getDate('start');
		    },
		    endDate() {
		        return this.getDate('end');
		    }
		},
		onLoad: function(option) {
			var that = this;
		    console.log(option.positive); //打印出上个页面传递的参数。
			console.log(option.back); //打印出上个页面传递的参数。
			this.xszxx = JSON.parse(decodeURIComponent(option.xszxx));
			this.license_positive = option.positive;
			this.license_side = option.back;
			if(this.xszxx != ''){
				that.license = false;
			}else{
				that.license = true;
			}
			// encodeURIComponent(JSON.stringify(item))
		},
		onShow() {
			// this.premise();
			this.UserInfo();
		},
		methods: {
			UserInfo(){
				var that = this;
				that.token = uni.getStorageSync('token');
				uni.request({
				    url: VUE_API_URL + '/user/info', 
					method:'POST',
				    data: {
				        
				    },
				    header: {
				        'Authori-zation': 'Bearer ' + that.token //自定义请求头信息
				    },
				    success: (res) => {
						var data = res.data.data;
						if(data.license_positive == '' || data.license_side == ''){
							that.license = false;
						}
				    }
				});	 
			},
			premise(){
				var that = this;
				that.token = uni.getStorageSync('token');
				uni.request({
				    url: VUE_API_URL + 'premise', 
					method:'POST',
				    data: {},
				    header: {
				        'Authori-zation': 'Bearer ' + that.token //自定义请求头信息
				    },
				    success: (res) => {
						let data = res.data.data;
						
				    }
				});	
			},
			IncreaseInformationClick(index){
				if(index == 1){
					uni.navigateTo({		//行驶证认证
						url: '../second/DrivingLicense'
					});
				}
			},
			bindPickerChange: function(e) {
			    this.index = e.target.value;
				console.log(this.index)
				if(this.index == 1){
					this.Driving = true;
				}else{
					this.Driving = false;
				}
			},
			bindPickerChange2: function(e) {
			    this.index2 = e.target.value
			},
			bindPickerChange3: function(e) {
			    this.index3 = e.target.value
			},
			TiJiaoClick(){
				var that = this;
				that.token = uni.getStorageSync('token');
				if(that.license == true && that.list[this.index] == '是'){
					uni.showToast({
					    title: '请先完成行驶证认证',
						icon:'none',
					    duration: 2000
					});
				}else{
					var a = JSON.stringify(that.xszxx);
					console.log(a)
					uni.request({
					    url: VUE_API_URL + 'user/submit', 
						method:'POST',
					    data: {
							type:'4',
							license_positive:that.license_positive,		//行驶证正面
							license_side:that.license_side,		    //行驶证反面
							room:that.index2,		            //有房凭证
							insurance:that.index3,		        //保单凭证
							license_list:a
						},
					    header: {
					        'Authori-zation': 'Bearer ' + that.token //自定义请求头信息
					    },
					    success: (res) => {
							let data = res.data.data;
							uni.showToast({
							    title: data.msg,
								icon:'none',
							    duration: 2000
							});
					    }
					});	
				}
			}
			
		},
	}
</script>

<style>
	.IncreaseInformationBottomInput{
		width: 650rpx;
		height: 95rpx;
		background: linear-gradient(-84deg, #DFBA94, #DFAE7C);
		box-shadow: 1rpx 3rpx 10rpx 0px rgba(0, 0, 0, 0.16);
		border-radius: 48rpx;
		line-height: 95rpx;
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #FFFFFF;
		margin: auto;
	}
	.IncreaseInformationBottom{
		width: 100%;
		background: #FFFFFF;
		padding-top: 20rpx;
		padding-bottom: 30rpx;
		text-align: center;
		position: fixed;
		bottom: 0;
	}
	page{
		background: #F8F8F8;
	}
	.SupplementHeadImg{
		width: 33rpx;
		height: 18rpx;
		float: right;
		position: absolute;
		top: 40rpx;
		right: 50rpx;
		/* top: 40rpx; */
	}
	.IncreaseInformationHead1{
		width: 100%;
		height: 100rpx;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #000000;
		padding: 0 50rpx;
		box-sizing: border-box;
		border-bottom: 1px solid #F8F8F8;
		background: #FFFFFF;
		position: relative;
		padding-top: 30rpx;
		box-sizing: border-box;
	}
	.IncreaseInformationHead{
		width: 100%;
		height: 100rpx;
		line-height: 100rpx;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #000000;
		padding: 0 50rpx;
		box-sizing: border-box;
		border-bottom: 1px solid #F8F8F8;
		background: #FFFFFF;
		position: relative;
	}
	.IncreaseInformation{
		width: 100%;
		height: 50rpx;
		line-height: 50rpx;
		background: #FBE5CE;
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #DFAF80;
		padding-left: 30rpx;
		box-sizing: border-box;
	}
</style>
